package com.henry.xman.bean

import com.intellij.openapi.application.ApplicationManager
import com.intellij.openapi.components.*
import java.io.Serializable

@Service
@State(name = "com.henry.XManConfig", storages = [Storage("XManConfig.xml", roamingType = RoamingType.PER_OS)])
class XManConfigService : PersistentStateComponent<XManConfigService.XManConfig> {

    class XManConfig : Serializable {
        //protoc cmd命令的路径
        var protocPath: String? = ""
    }

    private var config = XManConfig()

    override fun getState(): XManConfig {
        return config
    }

    override fun loadState(state: XManConfig) {
        config = state
    }

    companion object {
        @JvmStatic
        fun getInstance(): XManConfigService? {
            return ApplicationManager.getApplication().getService(XManConfigService::class.java)
        }
    }
}